/*
package com.noah.project.controller

import com.noah.project.global.Const
import com.noah.project.global.JsonManager
import com.noah.project.socket.MsgEvent
import io.socket.client.Ack
import io.socket.client.IO
import io.socket.client.Socket
import io.socket.emitter.Emitter
import org.junit.Test
import org.slf4j.LoggerFactory
import java.net.URISyntaxException
import java.util.*

class Test {
    val log = LoggerFactory.getLogger(CommentApiController::class.simpleName)
    //测试性能
    @Test
    @Throws(Exception::class)
    fun testNetty() {
        */
/*for (i in 1..5) {
            Thread(Runnable {
                connectSocket(i)
            }).run()
        }*//*

        connectSocket(333)
    }

    private var socket: Socket? = null

    fun connectSocket(i: Int) {
        try {
            */
/*if (socket != null && socket!!.connected()) {
                return
            }*//*

            val options = IO.Options()
            options.reconnectionAttempts = 7     // 重连尝试次数
            options.reconnectionDelay = 3000     // 失败重连的时间间隔(ms)
            options.timeout = 10000              // 连接超时时间(ms)
            options.forceNew = true
            options.transports = arrayOf("websocket")
            //options.query = "uid=" + LoginManager.getInstance().getUser().getUid();
            options.query = "uid=$i"
            socket = IO.socket(Const.BASE_HOST + ":8090/", options)
            socket!!.on(Socket.EVENT_CONNECT, object : Emitter.Listener {
                override fun call(vararg args: Any) {
                    log.info("连接成功EVENT_CONNECT")
                    sendMsg("我连接了...")
                }
            }).on(Socket.EVENT_CONNECT_ERROR, object : Emitter.Listener {
                override fun call(vararg args: Any) {
                    log.info("连接错误CONNECT_ERROR")
                }
            }).on(Socket.EVENT_CONNECT_TIMEOUT, object : Emitter.Listener {
                override fun call(vararg args: Any) {
                    log.info("连接超时CONNECT_TIMEOUT")
                }
            }).on(Socket.EVENT_PING, object : Emitter.Listener {
                override fun call(vararg args: Any) {
                    log.info("Socket.EVENT_PING")
                }
            }).on(Socket.EVENT_PONG, object : Emitter.Listener {
                override fun call(vararg args: Any) {
                    log.info("Socket.EVENT_PONG")
                }
            }).on(Socket.EVENT_DISCONNECT, object : Emitter.Listener {
                override fun call(vararg args: Any) {
                    log.info("连接断开EVENT_DISCONNECT")
                }
            }).on(Socket.EVENT_MESSAGE, object : Emitter.Listener {
                override fun call(vararg args: Any) {
                    log.info("收到:" + Arrays.toString(args))
                }
            })
            socket!!.connect()
        } catch (e: URISyntaxException) {
            throw RuntimeException(e)
        }

    }

    private fun sendMsg(message: String) {
        val msgEvent = MsgEvent()
        socket!!.emit(Socket.EVENT_MESSAGE, JsonManager.toJson(msgEvent), Ack { args -> log.info("发送收到:" + Arrays.toString(args)) })
    }
}
*/
